--
-- Author: yawei.zhu
-- Date: 2018-12-28 17:09:07
--
-- MainBranchConfirmView
--

local fileName = string.getModeName(...)
local ClassRef = class(fileName, app.mvc.ViewBase)

ClassRef.VIEW_ROOT_RES = Res.MainBranchConfirmScene

function ClassRef:init()
	self._ui.Button_quxiao:addClickEventListener(function()
		self:closeView()
	end)
	self._ui.Button_queding:addClickEventListener(function()
		executeFunc(self._onOperate, "reqSelectBranchTask", {curTaskId = self._curTaskId, nextTaskId = self._nextTaskId})
		self:closeView()
		app:sendMsg("TaskController", "closeBranchTaskDialog")
	end)
end

function ClassRef:updateView(data)
	if not data then return end

	self._curTaskId = data.curTaskId
	self._nextTaskId = data.nextTaskId
	self._ui.text:setString(data.desc)
	self._ui.card:findChild("role/Image"):loadTexture(data.img)

	self._ui.bg1:setOpacity(0)
	self._ui.Button_quxiao:setOpacity(0)
	self._ui.Button_queding:setOpacity(0)
	self._ui.text:setOpacity(0)

	self._ui.Button_quxiao:setCascadeOpacityEnabled(true)
	self._ui.Button_queding:setCascadeOpacityEnabled(true)

	-- 播放特效
	local timeline = self._ui.card:getTimeline()
	timeline:play("light", false)
	local info = timeline:getAnimationInfo("light")
	local duration = info.endIndex - info.startIndex
	dump(duration)
	scheduler.newCron(function()
		if not cc.isDead(self) then
			timeline:play("float", true)

			self._ui.bg1:fadeIn(0.2)
			self._ui.Button_quxiao:fadeIn(0.2)
			self._ui.Button_queding:fadeIn(0.2)
			self._ui.text:fadeIn(0.2)

		end
	end, duration * app:getAnimationInterval())
end

return ClassRef
